package com.zhou.util;

import java.util.Collection;
import java.util.Map;

public class Util {

    public static boolean isNotEmpty(Object obj){
        if(obj == null){
            return false;
        }
        if(obj instanceof String){
            String str = (String)obj;
            if(str.trim().length() > 0 && !str.trim().equals("null")){
               return true;
            }else{
                return false;
            }
        }else if(obj instanceof Map){
            Map map = (Map) obj;
            if(!map.isEmpty()){
                return true;
            }else{
                return false;
            }
        }else if(obj instanceof Collection){
            Collection collection = (Collection)obj;
            if(collection.size() > 0){
                return true;
            }else{
                return false;
            }
        }else if(obj.getClass().isArray()){
            Object[] objs = (Object[]) obj;
            if(objs.length > 0){
                return true;
            }else{
                return false;
            }
        }else{
            return true;
        }
    }

    public static boolean isEmpty(Object obj){
        return !isNotEmpty(obj);
    }
}
